\(\int \csc ^2(x) (a \cos (x)+b \sin (x)) \, dx\) [6]

   Optimal result
   Rubi [A] (verified)
   Mathematica [B] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 14, antiderivative size = 12 \[ \int \csc ^2(x) (a \cos (x)+b \sin (x)) \, dx=-b \text {arctanh}(\cos (x))-a \csc (x) \]

[Out]

-b*arctanh(cos(x))-a*csc(x)

Rubi [A] (verified)

Time = 0.04 (sec) , antiderivative size = 12, normalized size of antiderivative = 1.00, number of steps used = 5, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.286, Rules used = {3168, 3855, 2686, 8} \[ \int \csc ^2(x) (a \cos (x)+b \sin (x)) \, dx=-a \csc (x)-b \text {arctanh}(\cos (x)) \]

[In]

Int[Csc[x]^2*(a*Cos[x] + b*Sin[x]),x]

[Out]

-(b*ArcTanh[Cos[x]]) - a*Csc[x]

Rule 8

Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, x]

Rule 2686

Int[((a_.)*sec[(e_.) + (f_.)*(x_)])^(m_.)*((b_.)*tan[(e_.) + (f_.)*(x_)])^(n_.), x_Symbol] :> Dist[a/f, Subst[
Int[(a*x)^(m - 1)*(-1 + x^2)^((n - 1)/2), x], x, Sec[e + f*x]], x] /; FreeQ[{a, e, f, m}, x] && IntegerQ[(n -
1)/2] &&  !(IntegerQ[m/2] && LtQ[0, m, n + 1])

Rule 3168

Int[sin[(c_.) + (d_.)*(x_)]^(m_.)*(cos[(c_.) + (d_.)*(x_)]*(a_.) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(n_.), x_Sym
bol] :> Int[ExpandTrig[sin[c + d*x]^m*(a*cos[c + d*x] + b*sin[c + d*x])^n, x], x] /; FreeQ[{a, b, c, d}, x] &&
 IntegerQ[m] && IGtQ[n, 0]

Rule 3855

Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-ArcTanh[Cos[c + d*x]]/d, x] /; FreeQ[{c, d}, x]

Rubi steps \begin{align*} \text {integral}& = \int (b \csc (x)+a \cot (x) \csc (x)) \, dx \\ & = a \int \cot (x) \csc (x) \, dx+b \int \csc (x) \, dx \\ & = -b \text {arctanh}(\cos (x))-a \text {Subst}(\int 1 \, dx,x,\csc (x)) \\ & = -b \text {arctanh}(\cos (x))-a \csc (x) \\ \end{align*}

Mathematica [B] (verified)

Leaf count is larger than twice the leaf count of optimal. \(25\) vs. \(2(12)=24\).

Time = 0.05 (sec) , antiderivative size = 25, normalized size of antiderivative = 2.08 \[ \int \csc ^2(x) (a \cos (x)+b \sin (x)) \, dx=-a \csc (x)-b \log \left (\cos \left (\frac {x}{2}\right )\right )+b \log \left (\sin \left (\frac {x}{2}\right )\right ) \]

[In]

Integrate[Csc[x]^2*(a*Cos[x] + b*Sin[x]),x]

[Out]

-(a*Csc[x]) - b*Log[Cos[x/2]] + b*Log[Sin[x/2]]

Maple [A] (verified)

Time = 0.41 (sec) , antiderivative size = 17, normalized size of antiderivative = 1.42

method result size
parallelrisch \(b \ln \left (\csc \left (x \right )-\cot \left (x \right )\right )-a \csc \left (x \right )\) \(17\)
parts \(b \ln \left (\csc \left (x \right )-\cot \left (x \right )\right )-a \csc \left (x \right )\) \(17\)
default \(-\frac {a}{\sin \left (x \right )}+b \ln \left (\csc \left (x \right )-\cot \left (x \right )\right )\) \(19\)
risch \(-\frac {2 i a \,{\mathrm e}^{i x}}{{\mathrm e}^{2 i x}-1}-b \ln \left ({\mathrm e}^{i x}+1\right )+b \ln \left ({\mathrm e}^{i x}-1\right )\) \(41\)
norman \(\frac {-\frac {a}{2}-\frac {a \tan \left (\frac {x}{2}\right )^{4}}{2}-\tan \left (\frac {x}{2}\right )^{2} a}{\tan \left (\frac {x}{2}\right ) \left (1+\tan \left (\frac {x}{2}\right )^{2}\right )}+b \ln \left (\tan \left (\frac {x}{2}\right )\right )\) \(48\)

[In]

int(csc(x)^2*(a*cos(x)+b*sin(x)),x,method=_RETURNVERBOSE)

[Out]

b*ln(csc(x)-cot(x))-a*csc(x)

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 33 vs. \(2 (12) = 24\).

Time = 0.25 (sec) , antiderivative size = 33, normalized size of antiderivative = 2.75 \[ \int \csc ^2(x) (a \cos (x)+b \sin (x)) \, dx=-\frac {b \log \left (\frac {1}{2} \, \cos \left (x\right ) + \frac {1}{2}\right ) \sin \left (x\right ) - b \log \left (-\frac {1}{2} \, \cos \left (x\right ) + \frac {1}{2}\right ) \sin \left (x\right ) + 2 \, a}{2 \, \sin \left (x\right )} \]

[In]

integrate(csc(x)^2*(a*cos(x)+b*sin(x)),x, algorithm="fricas")

[Out]

-1/2*(b*log(1/2*cos(x) + 1/2)*sin(x) - b*log(-1/2*cos(x) + 1/2)*sin(x) + 2*a)/sin(x)

Sympy [A] (verification not implemented)

Time = 0.95 (sec) , antiderivative size = 24, normalized size of antiderivative = 2.00 \[ \int \csc ^2(x) (a \cos (x)+b \sin (x)) \, dx=- \frac {a}{\sin {\left (x \right )}} + \frac {b \log {\left (\cos {\left (x \right )} - 1 \right )}}{2} - \frac {b \log {\left (\cos {\left (x \right )} + 1 \right )}}{2} \]

[In]

integrate(csc(x)**2*(a*cos(x)+b*sin(x)),x)

[Out]

-a/sin(x) + b*log(cos(x) - 1)/2 - b*log(cos(x) + 1)/2

Maxima [A] (verification not implemented)

none

Time = 0.21 (sec) , antiderivative size = 24, normalized size of antiderivative = 2.00 \[ \int \csc ^2(x) (a \cos (x)+b \sin (x)) \, dx=-\frac {1}{2} \, b {\left (\log \left (\cos \left (x\right ) + 1\right ) - \log \left (\cos \left (x\right ) - 1\right )\right )} - \frac {a}{\sin \left (x\right )} \]

[In]

integrate(csc(x)^2*(a*cos(x)+b*sin(x)),x, algorithm="maxima")

[Out]

-1/2*b*(log(cos(x) + 1) - log(cos(x) - 1)) - a/sin(x)

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 33 vs. \(2 (12) = 24\).

Time = 0.28 (sec) , antiderivative size = 33, normalized size of antiderivative = 2.75 \[ \int \csc ^2(x) (a \cos (x)+b \sin (x)) \, dx=b \log \left ({\left | \tan \left (\frac {1}{2} \, x\right ) \right |}\right ) - \frac {1}{2} \, a \tan \left (\frac {1}{2} \, x\right ) - \frac {2 \, b \tan \left (\frac {1}{2} \, x\right ) + a}{2 \, \tan \left (\frac {1}{2} \, x\right )} \]

[In]

integrate(csc(x)^2*(a*cos(x)+b*sin(x)),x, algorithm="giac")

[Out]

b*log(abs(tan(1/2*x))) - 1/2*a*tan(1/2*x) - 1/2*(2*b*tan(1/2*x) + a)/tan(1/2*x)

Mupad [B] (verification not implemented)

Time = 20.68 (sec) , antiderivative size = 24, normalized size of antiderivative = 2.00 \[ \int \csc ^2(x) (a \cos (x)+b \sin (x)) \, dx=b\,\ln \left (\mathrm {tan}\left (\frac {x}{2}\right )\right )-\frac {a}{2\,\mathrm {tan}\left (\frac {x}{2}\right )}-\frac {a\,\mathrm {tan}\left (\frac {x}{2}\right )}{2} \]

[In]

int((a*cos(x) + b*sin(x))/sin(x)^2,x)

[Out]

b*log(tan(x/2)) - a/(2*tan(x/2)) - (a*tan(x/2))/2